Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

490
Views
php isset($_post[]) y javascript form.submit

por alguna razón, isset ($ _post) no funciona cuando uso js form.submit () cómo puedo resolver eso sin cambiar el tipo de entrada del botón para enviar y solo usando javascript de vainilla porque necesito ambos.

codigo html:

 <form name="user_verification" action="action.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name="email"><br> <input type="button" onclick="myFunction(this)" name="button" value="submit"> </form>

y aquí está el script php en el archivo action.php

 if($_SERVER['REQUEST_METHOD']=="POST") { if(isset($_POST['button'])) { echo 'yes'; }else{ echo 'no'; } }

y aquí está el javascript en el archivo action.js

 function myFunction(button) { //some code const form=button.parentNode; form.submit();}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En realidad, el problema no surgió del PHP. El valor de los botones se envía cuando ellos envían directamente el formulario (en este caso, parece imposible).

Sugerencia 1: use otro campo para verificar el envío del formulario.

 if($_SERVER['REQUEST_METHOD'] == 'POST') { if(isset($_POST['email'])) { echo 'yes'; } else { echo 'no'; } }

Sugerencia 2: agregue una entrada oculta en el HTML.

 <form name="user_verification" action="test.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name="email"><br> <input type="hidden" name="button" value="submit"> <input type="button" onclick="myFunction(this)"> </form>

Sugerencia 3: cambie el tipo de botón a oculto antes de enviarlo.

 function myFunction(button) { // some code button.setAttribute('type', 'hidden'); const form=button.parentNode; form.submit(); button.setAttribute('type', 'button'); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!